GBML manual / Text

draw_text_3d_scaled

draw_text_3d at any size: draws text in world space with the line curving away from you, and xscale and yscale make the whole line wider and taller (or smaller) the way they do in draw_text_warped. The curve grows with the text, so a depth means the same thing at any size. shape and depth work exactly as they do in draw_text_3d: depth goes up to 6, and TEXT_DRUM slides the word through a lens fixed on the middle of the screen. A negative xscale or yscale flips the whole line, curve and all (a yscale of -1 is a reflection). (x, y) is the same LEFT/CENTER/RIGHT anchor draw_text already uses, and the point the line grows from. Inside a Draw GUI event it is fixed to the screen instead, and (x, y) counts from the screen’s top-left pixel.

Works differently on Game Boy - The Game Boy cannot squeeze letters row by row: a short 3D text gets a copy behind it, TEXT_BULGE arches the line, TEXT_DRUM and TEXT_BAND show it only inside their lens (24 letters at most, drawn with sprites).

Works differently on Game Boy Color - The Game Boy Color cannot squeeze letters row by row: a short 3D text gets a copy behind it, TEXT_BULGE arches the line, TEXT_DRUM and TEXT_BAND show it only inside their lens (24 letters at most, drawn with sprites).

Sega Genesis: not available

On other consoles this differs: see Side by side and How the consoles differ.

Syntax

draw_text_3d_scaled(x, y, text, shape, depth, xscale, yscale)

Arguments

NameType
xreal
yreal
textstring
shapetext_shape
depthint
xscalereal
yscalereal

Returns

Nothing.

Description

draw_text_3d at any size. The line of text curves away from you like it is wrapped round a barrel or stuck on a sign that is tipped back, and xscale and yscale make the whole line wider or narrower and taller or shorter. A word that pops up big for a moment, a title that zooms in, a name written in huge letters - all with the curve.

A real capture - the word BOSS drawn three times with TEXT_BULGE at depth 5, one under the other, at 0.6 times, 1 times and 1.5 times their size. Every line is pinched to a point at the top and bottom of each letter in the same way, however big it isA real capture - the word BOSS drawn three times with TEXT_BULGE at depth 5, one under the other, at 0.6 times, 1 times and 1.5 times their size. Every line is pinched to a point at the top and bottom of each letter in the same way, however big it is
A real capture - the word BOSS drawn three times with TEXT_BULGE at depth 5, one under the other, at 0.6 times, 1 times and 1.5 times their size. Every line is pinched to a point at the top and bottom of each letter in the same way, however big it is

The same call three times, with only the scale changing: 0.6, 1 and 1.5. Real pictures from a Game Boy Advance ROM, cropped, with the 1.5 line at the bottom. The curve is the same shape in all three, because depth is a proportion, not a number of pixels.

The first five numbers are draw_text_3d's own: (x, y), the text, the shape and the depth. The last two are the scale. They work exactly the way they do in draw_text_warped, and this page does not repeat all of that:

shape and depth are the same too: TEXT_BULGE, TEXT_LEAN_BACK, TEXT_LEAN_FORWARD or TEXT_DRUM, and a depth from 0 to 6. Read draw_text_3d for what every depth looks like and why the deep ones (4 to 6) want a big, bold font. Depth 0 draws the scaled line flat and costs none of the row-by-row effects below.

The curve grows with the text

depth says how much of its width the far edge of the letters keeps, as a share of the whole. It is not a number of pixels. That is what makes it behave when the size changes: drawn twice as big, the line has a curve that is twice as long and exactly the same shape, so depth 5 is depth 5 whether the line is a little caption or a huge title. You never have to work out a new depth for a new size.

A real capture, 16 frames played in a loop - the word BOSS with TEXT_BULGE at depth 5 pops up from a small size to 1.6 times its size, then settles back to normal size. The curve of the letters stays the same shape the whole time. The first frame, which is all a viewer that cannot animate shows, is the word at its normal size.A real capture, 16 frames played in a loop - the word BOSS with TEXT_BULGE at depth 5 pops up from a small size to 1.6 times its size, then settles back to normal size. The curve of the letters stays the same shape the whole time. The first frame, which is all a viewer that cannot animate shows, is the word at its normal size.
A real capture, 16 frames played in a loop - the word BOSS with TEXT_BULGE at depth 5 pops up from a small size to 1.6 times its size, then settles back to normal size. The curve of the letters stays the same shape the whole time. The first frame, which is all a viewer that cannot animate shows, is the word at its normal size.

The same call with the scale changing every frame (16 pictures, two frames apart, played at about half the speed of the console): the word pops to 1.6 times its size and settles back. Look at the top and bottom of each letter: it is pinched the same amount at every size. A viewer that does not animate shows the first frame.

Flipping it

A negative xscale or yscale flips the whole line, and the curve is flipped with it. That is what a mirror does, so the best use for it is a reflection. A line that leans back (the top shrinks away) and the same line with a yscale of -1 underneath it, upside down, is a word reflected in water.

A real capture - the words LONG AGO drawn leaning back, so the top of the letters is narrow, and under them the same call with a yscale of -1, which draws the words upside down with the narrow edge at the bottom, like a reflection in waterA real capture - the words LONG AGO drawn leaning back, so the top of the letters is narrow, and under them the same call with a yscale of -1, which draws the words upside down with the narrow edge at the bottom, like a reflection in water
A real capture - the words LONG AGO drawn leaning back, so the top of the letters is narrow, and under them the same call with a yscale of -1, which draws the words upside down with the narrow edge at the bottom, like a reflection in water

Two calls: TEXT_LEAN_BACK at the top, and the same words with yscale of -1 below. The reflection's narrow edge is at the bottom, because the whole line, curve included, was turned upside down. A reflection made like this has exactly the same letters, one for one.

A TEXT_LEAN_BACK drawn with a yscale of -1 looks like a TEXT_LEAN_FORWARD turned upside down. A negative xscale writes the words backwards: draw_text_3d_scaled(x, y, "Hi", TEXT_BULGE, 3, -1, 1) draws iH, curved.

How big can it get

The Game Boy Advance draws a stretched sprite only inside a box twice as wide and twice as tall as the sprite, and anything outside that box is cut off. Text is made of sprites, so this is the same rule draw_text_warped has, and its page ("How far it can turn and grow") says what it means for text: a line up to 2 times its normal size is whole, and past 2 the ends of it are cut off. Making a line smaller never cuts anything.

A line of 3D text cannot also be turned. The row sizes belong to the line as it is drawn, and a turn would carry them away from the rows they were made for. Use draw_text_warped to turn text, without the curve.

One line only

The curve is made for a single line of text. A "\n" in the string ends the text there: only the first line is drawn, and what follows is left out. To curve several lines, draw each with its own call.

What it costs

It costs what draw_text_3d costs, and a little more memory:

Ask for more than there is and the game stops, in a development build, with a message that names every call that is holding a slot. The line has already been drawn flat, at the size you asked for, when it stops, and a release build, which has no such stop, simply shows it flat. The effect never fails to appear: you are told. Depths 4 to 6 need a font drawn from 32 pixel tall sprites; with a smaller font the line is drawn at depth 3, and a development build says so once in its log.

Example

text_align(ALIGN_CENTER);
draw_text_3d_scaled(x, y - 24, "BOSS", TEXT_BULGE, 5, 1.5, 1.5);

A title, centered above this instance, pinched at the top and bottom of every letter like a barrel seen close up, and one and a half times as big as draw_text_3d would draw it (depth 5 needs a bold 32 pixel font).

text_align(ALIGN_CENTER);
draw_text_3d_scaled(x, y - 44, "LONG AGO", TEXT_LEAN_BACK, 5, 1, 1);
draw_text_3d_scaled(x, y - 4, "LONG AGO", TEXT_LEAN_BACK, 5, 1, -1);

A line that leans back, and under it the same line upside down: a reflection. Two 3D texts at once is all the console has room for.

text_align(ALIGN_CENTER);
var size = wave(0.6, 1.5, 90, 0);
draw_text_3d_scaled(x, y, "WARNING", TEXT_BULGE, 4, size, size);

A word that breathes between 0.6 and 1.5 times its size, once every 90 frames, curved all the time.

On the GBA

Costs what draw_text_3d costs - ONE of the hardware’s 32 affine matrices (the same one draw_text_warped’s scale needs, not a second) and TWO of the console’s 8 row-by-row (H-Blank) effects, for as long as the call keeps being made - plus 640 bytes of memory (nothing in the cartridge) and about 11,000 cycles (4% of a frame) on a frame where it moved up or down two rows or changed size, shape or depth. A room transition keeps two of the eight for itself, so at most three 3D things (a text or a sprite) can be on screen at once. Every letter gets a sprite of its own, so every letter leans by exactly what its own row asks and a word never leans in clumps. That holds for a word of up to 12 letters (spaces do not count). A longer word is still drawn, but its letters share sprites, up to four to a sprite, so it leans in clumps of letters; a development build says so once in the log, and drawing a long line as two calls keeps it even. Each letter counts toward the 128 sprites the screen can show at once, so a 12-letter word costs 12 where the same word in draw_text costs 3. Asking for more than there is stops the game with a message that names every call holding a slot (a release build draws the line flat, at the size you asked for, instead). depth is a proportion, not a number of pixels: how much of its width the far edge of the line keeps, so depth 3 is depth 3 at any size, and 0 draws the scaled line flat and costs no row-by-row effect. xscale and yscale of exactly 1 draw what draw_text_3d draws, row for row. A negative scale mirrors the whole line, curve included, so TEXT_LEAN_BACK drawn with a yscale of -1 is a TEXT_LEAN_FORWARD upside down; 0 still has no sign to flip by, so it reads as the smallest size (0.01), as in draw_text_warped. The console draws a scaled sprite inside a box twice its size, so past 2 times bigger the ends of the line are cut off (draw_text_warped explains the rule). Depths 4 to 6 still need a font drawn from sprites 32 pixels tall (a smaller font is drawn at depth 3 and a development build says so in the log). Changing xscale or yscale on every frame rebuilds the letters on every frame, as it does for draw_text_warped. It cannot be turned: use draw_text_warped for that, without the curve.

See also: draw_text_3ddraw_text_warpeddraw_sprite_3d_scaled